package com.derbysoft.ota.application.translator.rq;

import com.derbysoft.modules.eip.translator.Translator;
import com.derbysoft.remote.dswitch.generic.constants.AgeQualifyingType;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;

public class AgeQualifyingTypeTranslator implements Translator<String, AgeQualifyingType> {

    public static BiMap<String, AgeQualifyingType> ota2switch = HashBiMap.create();
    public static final String ADULT = "10";
    public static final String CHILD = "8";

    static {
        initialize();
    }

    private static void initialize() {
        ota2switch.put(ADULT, AgeQualifyingType.ADULT);
        ota2switch.put(CHILD, AgeQualifyingType.CHILD);
    }

    @Override
    public AgeQualifyingType translate(String source) {
        AgeQualifyingType ageQualifyingType = ota2switch.get(source);
        if (ageQualifyingType == null) {
            throw new IllegalArgumentException("Invalid age qualifying type [" + source + "]");
        }
        return ageQualifyingType;
    }

}
